from uliweb.form import *
from uliweb.i18n import ugettext_lazy as _

class NewCategoryForm(Form):
    form_buttons = Submit(value=_('Create'), _class=".submit")

    name = StringField(label=_('Category Name:'), required=True)
    id = HiddenField()
    
#    def validate_name(self, data):
#        from uliweb.orm import get_model
#        
#        Group = get_model('group')
#        group = Group.get(Group.c.name==data)
#        if group:
#            raise ValidationError, 'Group "%s" is already existed!' % data

class UploadForm(Form):
    form_buttons = Submit(value=_('Upload'), _class=".submit")

    filename = FileField(label=_('Filename:'), required=True)
    description = TextField(label=_('Description:'))
    category = SelectField(label=_('Category:'), choices=[('', '------')], default='-1', required=True)
    id = HiddenField()

class EditForm(Form):
    form_buttons = Submit(value=_('Save'), _class=".submit")
    
    description = TextField(label=_('Description:'))
    category = SelectField(label=_('Category:'), choices=[('', '------')], default='-1', required=True)
    id = HiddenField()
    